
cc.Class({
    extends: cc.Component,

    properties: {

        mSpeed: {

            default:1,

            type:cc.Float,

            tooltip:"鱼的速度,1-10, step =0.1",

            min:0.1,

            max:10,
            
        }
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    // 用 update 实现可能更好用

    start () {

        // 
        let x = this.node.x;
        let width = cc.winSize.width;

        let duration = 5 - (this.node.x + width/2 ) / width * 5;

        let seqaction = cc.sequence(
            cc.moveTo(duration,width/2 ,this.node.y),
            cc.flipX(true),
            cc.moveTo(duration,x,this.node.y),
            cc.moveTo(5- duration,- width /2,this.node.y),            
            cc.flipX(false),
            cc.moveTo(5- duration,x ,this.node.y),
        )

        // this.node.runAction(cc.repeatForever(seqAction));
        let action = cc.speed(cc.repeatForever(seqaction),this.mSpeed);
        this.node.runAction(action);

    },

    // update (dt) {},
});
